'use strict';

/** @type {import('sequelize-cli').Migration} */
module.exports = {
  async up (queryInterface, Sequelize) {
    /**
     * Add altering commands here.
     *
     * Example:
     * await queryInterface.createTable('users', { id: Sequelize.INTEGER });
     */
    const { STRING, INTEGER, BOOLEAN, DATE } = Sequelize;

    await queryInterface.createTable('admin', {
      id: {
        type: INTEGER,
        autoIncrement: true,
        primaryKey: true,
        comment: '表ID',
      },
      username: {
        type: STRING(32),
        allowNull: true,
        comment: '账号',
      },
      password: {
        type: STRING(32),
        allowNull: true,
        comment: '密码',
      },
      nickName: {
        type: STRING(32),
        allowNull: true,
        comment: '昵称',
      },
      state: {
        type: BOOLEAN,
        defaultValue: true,
        comment: '账号状态',
      },
      token: {
        type: STRING(255),
        allowNull: true,
        comment: '密钥key',
      },
      createdAt: {
        type: DATE,
        allowNull: false,
      },
      updatedAt: {
        type: DATE,
        allowNull: false,
      },
    })
  },

  async down (queryInterface, Sequelize) {
    /**
     * Add reverting commands here.
     *
     * Example:
     * await queryInterface.dropTable('users');
     */
    await queryInterface.dropTable('admin');
  }
};
